<?php
if ($messageFile != "")
{
	$messageFile = $langDir.$messageFile;
	if (file_exists($messageFile))
	{
		$messages = simplexml_load_file($messageFile);
	} 
	else
	{
		exit("Can't open messages file: ".$messageFile."place message bundle xml files in the /IGLocal/lang directory use relative urls in gadget xml source e.g. 'ALL_ALL.xml'");
	}

	//replace messages
	foreach ($messages->msg as $message)
	{
		if ($useExternalGadgetFiles)
		{
			$gadgetHtml = str_replace("__MSG_".$message['name']."__", $message, $gadgetHtml);
			$gadgetCss = str_replace("__MSG_".$message['name']."__", $message, $gadgetCss);
			$gadgetJs = str_replace("__MSG_".$message['name']."__", $message, $gadgetJs);
		}
		else
		{
			$gadgetContent = str_replace("__MSG_".$message['name']."__", $message, $gadgetContent);
		}
	}
}
?>